package com.vhall.component.controller.interactive;

import com.vhall.component.controller.interactive.facade.QuestionInnerFacade;
import com.vhall.component.entity.account.dto.IndexDto;
import com.vhall.component.entity.export.dto.AdminExportCommonQueryCondition;
import com.vhall.component.entity.interactive.vo.QuestionNumReqVO;
import com.vhall.component.entity.interactive.vo.QuestionNumRspVO;
import com.vhall.component.entity.interactive.vo.QuestionPageRspVO;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.framework.common.exception.BusinessException;
import com.vhall.component.plugin.common.exception.BizErrorCode;
import com.vhall.component.service.interactive.QuestionAdminService;
import com.vhall.component.service.interactive.QuestionService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author guoxin.wang
 * @date 2021-06-11 16:36
 */
@VhallComponent
public class QuestionInnerController implements QuestionInnerFacade {

    @Autowired
    private QuestionService questionService;

    @Autowired
    private QuestionAdminService questionAdminService;

    @Override
    public QuestionPageRspVO<Integer> queryQuesAccounts(String roomId, String startTime, int page, int pageSize, boolean queryCount) {
        if (StringUtils.isBlank(roomId) || null == startTime) {
            throw new BusinessException(BizErrorCode.BIZ_INVALID_PARAM);
        }
        return questionService.queryQuesAccounts(roomId, startTime, page, pageSize, queryCount);
    }

    @Override
    public Integer queryAllPartakeAccountsCount(String roomId, String startTime) {
        if (StringUtils.isBlank(roomId) || null == startTime) {
            throw new BusinessException(BizErrorCode.BIZ_INVALID_PARAM);
        }
        return questionService.queryAllPartakeAccountsCount(roomId, startTime);
    }

    @Override
    public IndexDto getCount(String beginTime) {
        return questionService.getCount(beginTime);
    }

    @Override
    public QuestionNumRspVO getQuestionNum(QuestionNumReqVO reqVO) {
        return questionService.statNum(reqVO);
    }

    @Override
    public Integer countForAdminExport(AdminExportCommonQueryCondition condition) {
        return questionAdminService.countForAdminExport(condition);
    }
}
